<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="${pageContext.request.contextPath}/static/js/echarts.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
</head>
<body>
<div id="main" style="width: 700px;height:500px;"></div>

<script type="text/javascript">

    window.onload = function(){
        $.ajax({
            url: "http://localhost:8080/data/barVO",
            type: "POST",
            success: function(data){
                //console.log(data.names);
                //console.log(data.values);
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('main'));

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '各类商品销量统计'
                    },
                    tooltip: {},
                    legend: {
                        data: ['销量']
                    },
                    xAxis: {
                        data: data.names
                    },
                    yAxis: {},
                    series: [
                        {
                            name: '销量',
                            type: 'bar',
                            data: data.values
                        }
                    ]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        });
    }

</script>
</body>
</html>
